int cmp(int* x, int* y)
{
    return *x - *y;
}

int* findErrorNums(int* nums, int numsSize, int* returnSize) {
    int* a = (int*)malloc(sizeof(int) * 2);
    int sum = 0;
    for (int i = 0; i < numsSize; i++)
    {
        sum = sum + nums[i] - (i + 1);
    }
    qsort(nums, numsSize, sizeof(int), cmp);
    int i = 0;
    for (i = 0; i < numsSize - 1; i++)
    {
        if (nums[i] == nums[i + 1])
        {
            break;
        }
    }
    int n = nums[i] - sum;
    *returnSize = 2;
    a[0] = nums[i];
    a[1] = n;
    return a;
}